import gtk
import os 

def populate(self):
    self.local_treemodel.clear()
    for row in self.local.list_file():
        self.local_treemodel.append([ row[0], row[1], row[2], row[3], row[4] ])  
    
def treeview_clicked(self):
    treeselection = self.local_treeview.get_selection()
    (tmp_model, tmp_iter) = treeselection.get_selected()
    type = tmp_model.get_value(tmp_iter, 0)
    name = tmp_model.get_value(tmp_iter, 2)
    if type == "directory":
        self.local.cwd(name)
        populate(self)
        self.update_localpath()
    else:
        open = os.system("gnome-open '" + name +"'")
def on_treeview_button_press_event(self, treeview, event):
    if event.button == 3:
        x = int(event.x)
        y = int(event.y)
        time = event.time
        pthinfo = treeview.get_path_at_pos(x, y)

        if self.connection.get_status() == False:
            self.local_popmenu.get_widget('upload').set_sensitive(False)
        if pthinfo is not None:
            path, col, cellx, celly = pthinfo
            treeview.grab_focus()
            treeview.set_cursor( path, col, 0)
            self.local_popmenu.get_widget('localmenu').popup( None, None, None, event.button, time)
        return 1